import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.Connection;

/**
 * @author 黎志雄
 * 创建于2019-2-18
 *
 * Jakarta EE 课程
 */

public class connect {

    public static Connection getConnect(String s)
    {
        try
        {
            InitialContext context=new InitialContext();
            DataSource dataSource=(DataSource)context.lookup(s);

            return dataSource.getConnection();
        }
        catch(Exception e){
           System.out.println("error");
            return null;

        }



    }

}